package com.yehun.admin.models;

import com.yehun.entity.User;
import com.yehun.enums.StatusEnum;
import com.yehun.enums.UserTypeEnum;
import com.yehun.utils.EnumUtils;
import com.yehun.utils.MD5Utils;
import lombok.Data;

@Data
public class UserModel {

    private int id;
    private String name;
    private String email;
    private String password;
    private int type;
    private int status;

    public User mapper() {
        User user = new User();
        user.setName(this.name);
        user.setEmail(this.email);
        user.setPassword(MD5Utils.md5(this.password));
        user.setType(EnumUtils.get(UserTypeEnum.class, this.type));
        user.setStatus(EnumUtils.get(StatusEnum.class, this.status));
        return user;
    }

}
